//
//  MyGiftTableViewCell.m
//  Molian
//
//  Created by xiaocankeji on 15/8/12.
//  Copyright (c) 2015年 xiaocan. All rights reserved.
//

#import "MyGiftTableViewCell.h"

@implementation MyGiftTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat CellHeight = 84;
        CGFloat Cellwidth = DeviceWidth;
        
//        UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, DeviceWidth, 84)];
//        backgroundImageView.image = [UIImage imageNamed:@"giftCellImage"];
//        backgroundImageView.userInteractionEnabled = YES;
//        self.backgroundView = backgroundImageView;
        //用户
        self.userAvatarImg = [[UIImageView alloc]init];
        self.userAvatarImg.frame = CGRectMake(8, (CellHeight-65)/2, 65, 65);
        self.userAvatarImg.layer.masksToBounds = YES;//开启圆角
        [self.userAvatarImg.layer setCornerRadius:4];
        [self.userAvatarImg setContentMode:UIViewContentModeScaleAspectFill];
        [self.topContentView addSubview:self.userAvatarImg];
        
        self.userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(78, 16, DeviceWidth-134, 20)];
        [self labelStyle:self.userNameLabel];
        self.userNameLabel.textColor = RGBA(51, 51, 51, 1);
        self.userNameLabel.font = [UIFont fontWithName:FontName size:16];
        [self.topContentView addSubview:self.userNameLabel];
        
        //礼物头像
        self.giftAvatarImg = [[UIImageView alloc]init];
        self.giftAvatarImg.frame = CGRectMake(78, 36, 40, 40);
        self.giftAvatarImg.layer.masksToBounds = YES;//开启圆角
        [self.giftAvatarImg.layer setCornerRadius:4];
        [self.giftAvatarImg setContentMode:UIViewContentModeScaleAspectFill];
        [self.topContentView addSubview:self.giftAvatarImg];
        //礼物名字
        self.giftNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(78+45, 36, DeviceWidth-134, 16)];
        [self labelStyle:self.giftNameLabel];
        self.giftNameLabel.textColor = APPCOLOR(1);
        self.giftNameLabel.font = [UIFont fontWithName:FontName size:16];
        [self.topContentView addSubview:self.giftNameLabel];
        
       
        //礼物说明
        self.giftSignatureLabel = [[UILabel alloc]initWithFrame: CGRectMake(78+45, 36+20, Cellwidth-86, 16)];
        [self labelStyle:self.giftSignatureLabel];
        self.giftSignatureLabel.textColor = RGBA(51, 51, 51, 1);
        self.giftSignatureLabel.font = [UIFont fontWithName:FontName size:14];
        [self.topContentView addSubview:self.giftSignatureLabel];
        //礼物的价格
        self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(DeviceWidth-100, 16, 85, 24)];
        self.timeLabel.textColor = RGBA(133, 133, 133, 1);
        self.timeLabel.font = [UIFont fontWithName:FontName size:13];
        self.timeLabel.textAlignment = NSTextAlignmentRight;
        [self.topContentView addSubview:self.timeLabel];
        
        
    }
    return self;
}
-(UILabel *)labelStyle:(UILabel *)label//统一风格
{
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentLeft;
    label.font = [UIFont fontWithName:FontName size:10];
    return label;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
